hysop.backend.host.python.operator.analytic module

class hysop.backend.host.python.operator.analytic.PythonAnalyticField(field, formula, variables, extra_input_kwds=None, **kwds)[source]

Bases: HostOperator

Applies an analytic formula, given by user, on its field. Formula is given as a python method that operates on numpy arrays.

Initialize a Analytic operator on the python backend.

Apply a user-defined formula onto a field, possibly dependent on space variables and external fields/parameters.

Parameters:
  • field (hysop.field.continuous_field.ScalarField) – Continuous field to be modified.

  • formula (callable) –

    The formula to be applied onto the field. Should have the following arguments:

    field: the discrete field being modified. coords: the coordinates (x0, …, xN) of the field being modified. **kwds: extra keywords contained in extra_input_kwds.

  • variables (dict) – Dictionary of fields as keys and topology descriptors as values.

  • extra_input_kwds (dict, optional) – Extra inputs that will be forwarded to the formula. Fields and Parameters are handled correctly as input requirements. If the output field is modified inplace, it should be added to extra_input_kwds.

  • kwds (dict, optional) – Base class arguments.

apply(**kwds)

Abstract method that should be implemented. Applies this node (operator, computational graph operator…).

discretize()[source]

By default, an operator discretize all its variables. For each input continuous field that is also an output field, input topology may be different from the output topology.

After this call, one can access self.input_discrete_fields and self.output_discrete_fields, which contains input and output dicretised fields mapped by continuous fields.

self.discrete_fields will be a tuple containing all input and output discrete fields.

Discrete tensor fields are built back from discretized scalar fields and are accessible from self.input_tensor_fields, self.output_tensor_fields and self.discrete_tensor_fields like their scalar counterpart.

classmethod supports_mpi()[source]

Return True if this operator was implemented to support multiple mpi processes.